//
//  ServerNameViewController.m
//  LOL_PalmarHelper
//
//  Created by dllo on 15/6/25.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "ServerNameViewController.h"

@interface ServerNameViewController ()

@end

@implementation ServerNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
    self.navigationItem.title = @"召唤师战绩";
    
    
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar1.png"] forBarMetrics:UIBarMetricsDefault];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(leftButtonAction)];
    
    
    self.myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.size.width, self.view.bounds.size.height  - 64)];
    self.myWebView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.myWebView.delegate = self;
    [self.view addSubview:self.myWebView];
    
    NSString *url = [self.playerName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//    NSLog(@"--------%@",self.server);
//    NSLog(@"-------%@",self.playerName);
    NSString *url2 = [self.server stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSLog(@"url = %@,url2 = %@",url,url2);
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://zdl.mbox.duowan.com/phone/playerDetailNew.php?lolboxAction=toPlayerDetail&sn=%@&pn=%@&sk=&v=224&timestamp=1435192844590",url2,url]]];
    
    
    [self.myWebView loadRequest:request];
    
    
    
    
    
    
        
}






//-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
//{
//    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
//        
//        NSLog(@"用户触击了一个链接");
//        [self.myWebView stopLoading];
//        
//        NSLog(@"request = %@",request);
//        
//        NSString *url = [self.playerName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//        NSLog(@"--------%@",self.server);
//        NSString *url2 = [self.server stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
////        NSLog(@"url = %@,url2 = %@",url,url2);
//        
//        request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://zdl.mbox.duowan.com/phone/matchListNew.php?sn=%@&pn=%@&v=224&hero=&timestamp=1435225777",url2,url]]];
//        
//        [self.myWebView loadRequest:request];
//        
//        return YES;
//    }
//    
//    else if (navigationType == UIWebViewNavigationTypeFormSubmitted)
//    {
//        NSLog(@"用户提交了一个表单");
//        
//        return YES;
//        
//        
//    }
//    
//    else if (navigationType == UIWebViewNavigationTypeBackForward)
//    {
//        NSLog(@"用户触击前进或返回按钮");
//        
//        return YES;
//        
//        
//        
//        
//    }
//    
//    else if (navigationType == UIWebViewNavigationTypeReload)
//    {
//        NSLog(@"用户重复提交表单");
//        
//        return YES;
//        
//        
//        
//        
//    }
//    
//    else if (navigationType == UIWebViewNavigationTypeFormResubmitted)
//    {
//        NSLog(@"用户触击重新加载的按钮");
//        
//        return YES;
//        
//    }
//    
//    
//    else if (navigationType == UIWebViewNavigationTypeOther)
//    {
//        NSLog(@"发生其它行为");
//        
//        return YES;
//        
//    }
//    
//    
//    //UIWebViewNavigationTypeLinkClicked，用户触击了一个链接。
//    //UIWebViewNavigationTypeFormSubmitted，用户提交了一个表单。
//    //UIWebViewNavigationTypeBackForward，用户触击前进或返回按钮。
//    //UIWebViewNavigationTypeReload，用户触击重新加载的按钮。
//    //UIWebViewNavigationTypeFormResubmitted，用户重复提交表单
//    //UIWebViewNavigationTypeOther，发生其它行为。
//    
//    NSLog(@"===========333333333");
//    
//    
//    return YES;
//    
//}


-(void)webViewDidFinishLoad:(UIWebView *)webView
{
 
//    NSLog(@"加载完成");
    
}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    
//    NSLog(@"开始加载");
    
}



-(void)leftButtonAction
{


[self dismissViewControllerAnimated:YES completion:^{
    
    
}];


}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
